package com.ruoyi.system.weather_forecast.service.impl;

import java.util.Date;
import java.util.List;

import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.weather_forecast.domain.WeatherForecast;
import com.ruoyi.system.weather_forecast.mapper.WeatherForecastMapper;
import com.ruoyi.system.weather_forecast.service.IWeatherForecastService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 天气预报Service业务层处理
 *
 * @author ruoyi
 * @date 2024-06-21
 */
@Service
public class WeatherForecastServiceImpl implements IWeatherForecastService
{
    @Autowired
    private WeatherForecastMapper weatherForecastMapper;

    /**
     * 查询天气预报
     *
     * @param id 天气预报主键
     * @return 天气预报
     */
    @Override
    public WeatherForecast selectWeatherForecastById(String id)
    {
        return weatherForecastMapper.selectWeatherForecastById(id);
    }

    /**
     * 查询天气预报列表
     *
     * @param weatherForecast 天气预报
     * @return 天气预报
     */
    @Override
    public List<WeatherForecast> selectWeatherForecastList(WeatherForecast weatherForecast)
    {
        return weatherForecastMapper.selectWeatherForecastList(weatherForecast);
    }

    /**
     * 新增天气预报
     *
     * @param weatherForecast 天气预报
     * @return 结果
     */
    @Override
    public int insertWeatherForecast(WeatherForecast weatherForecast)
    {
        return weatherForecastMapper.insertWeatherForecast(weatherForecast);
    }

    /**
     * 修改天气预报
     *
     * @param weatherForecast 天气预报
     * @return 结果
     */
    @Override
    public int updateWeatherForecast(WeatherForecast weatherForecast)
    {
        return weatherForecastMapper.updateWeatherForecast(weatherForecast);
    }

    /**
     * 批量删除天气预报
     *
     * @param ids 需要删除的天气预报主键
     * @return 结果
     */
    @Override
    public int deleteWeatherForecastByIds(String[] ids)
    {
        return weatherForecastMapper.deleteWeatherForecastByIds(ids);
    }

    /**
     * 删除天气预报信息
     *
     * @param id 天气预报主键
     * @return 结果
     */
    @Override
    public int deleteWeatherForecastById(String id)
    {
        return weatherForecastMapper.deleteWeatherForecastById(id);
    }

    @Override
    public int insertOrUpdateWeatherForecast(WeatherForecast weatherForecast) {
        weatherForecast.setId(IdUtil.getSnowflakeNextIdStr());
        weatherForecast.setCreatedAt(new Date());
        weatherForecast.setUpdatedAt(new Date());
//        weatherForecast.setCreatedBy(SecurityUtils.getUserId().toString());
//        weatherForecast.setUpdatedBy(SecurityUtils.getUserId().toString());
        return weatherForecastMapper.insertOrUpdateWeatherForecast(weatherForecast);
    }

    @Override
    public int deleteWeatherForecastByDateText(String dateText) {
        return weatherForecastMapper.deleteWeatherForecastByDateText(dateText);
    }

    @Override
    public int creates(List<WeatherForecast> weatherForecasts) {

        return weatherForecastMapper.creates(weatherForecasts);
    }
}
